﻿using System;
using NUnit.Framework;
using Smartkernel;

namespace Smartkernel.NUnitTest.
{
    [Category("Core")]
    [TestFixture]
    public class SmartRandomTest
    {
        [Test]
        public void Test()
        {
            //【01】随机数字的测试（涉及方法：Next）
            for (int i = 0; i < 100; i++)
            {
                int random = SmartRandom.Next(-5, 5);
                Assert.AreEqual(random >= -5 && random <= 5, true);
            }

            //【02】指定范围的随机数（涉及方法：Next）
            string scope = "ABCDEF012345中华人民共和国";
            Assert.AreEqual(SmartRandom.Next(scope, 5).Length, 5);
            for (int i = 0; i < 100; i++)
            {
                Assert.AreEqual(scope.Contains(SmartRandom.Next(scope, 1)), true);
            }

            //【03】随机表达式（涉及方法：NextExpression）
            int result = 0;
            string expression = "";
            for (int i = 0; i < 5; i++)
            {
                expression = SmartRandom.NextExpression(out result);
                Assert.AreEqual(SmartMath.DynamicEval(expression, false), result);
            }

            //【04】随机大写字符串（涉及方法：NextCapitalString）
            Assert.AreEqual(SmartRandom.NextCapitalString(4).Length, 4);
        }
    }
}
